import com.hdrx.fundhelper.dao.pojo.User;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author: houdx
 * @description:
 * @date: 2023/7/10 10:25
 */
public class testList {

    //测试list 去重对象
    public static void main(String[] args) {

        List<User> l1 = new ArrayList<>();
        List<User> l2 = new ArrayList<>();
        List<User> l3 = new ArrayList<>();
        List<User> l4 = new ArrayList<>();
        User user1 = new User();
        user1.setId("1");
        user1.setPassword("123");
        user1.setUsername("hhh");

        User user2 = new User();
        user2.setId("2");
        user2.setPassword("1234");
        user2.setUsername("ddd");

        User user3 = new User();
        user3.setId("3");
        user3.setPassword("12345");
        user3.setUsername("xxx");
        l1.add(user1);

        l2.add(user1);
        l2.add(user2);

        l3.add(user1);
        l3.add(user2);
        l3.add(user3);

        l4.addAll(l1);
        l4.addAll(l2);
        l4.addAll(l3);
        System.out.println("-----------原始数据--------------");
        System.out.println(l4);

        System.out.println("------------stream-------------");
        List<User> collect = l4.stream().distinct().collect(Collectors.toList());
        System.out.println(collect);

        System.out.println("------------set-------------");

        HashSet set = new HashSet();
        set.addAll(l4);
        System.out.println(set);

        System.out.println("-----------set1--------------");
        Set<User> collect1 = new HashSet<>(l4);
        List<User> l5 = new ArrayList<>(collect1);

        System.out.println(collect1);
        System.out.println(">>>>>>>>>>>>>l5>>>>>>>>>>>>");
        System.out.println(l5);


    }
}
